/**
 * @file mock模拟数据
 *
 * @author liubin29(liubin29@baidu.com)
 * 2017年3月28日
 */

let fs = require('fs');
let path = require('path');

module.exports = function* (next) {
    let filename = path.resolve(__dirname + '/../.tmp/' + this.params.pageId + '.json');

    if (fs.existsSync(filename)) {
        let body = fs.readFileSync(filename, 'utf8');

        this.body = {
            status: 0,
            data: JSON.parse(body)
        };
    }
    else {
        this.body = {
            status: 0,
            data: {}
        };
    }
};
